import { createRouter, createWebHashHistory } from 'vue-router'

import routerBeforeEachdConfig from './router.config'


// import Login from '../components/Login.vue'
// import Home from '../components/Home.vue'
// import Welcome from '../components/Welcome.vue'
const Login  = () => import(/* webpackChunkName: "login_home" */ '../components/Login.vue');
const Home  = () => import(/* webpackChunkName: "login_home" */ '../components/Home.vue');
const Welcome  = () => import(/* webpackChunkName: "login_home" */ '../components/Welcome.vue');

// import User from '../components/user/User.vue'
// import Rights from '../components/power/Rights.vue'
// import Roles from '../components/power/Roles.vue'
const User  = () => import(/* webpackChunkName: "Users_Rights" */ '../components/user/User.vue');
const Rights  = () => import(/* webpackChunkName: "Users_Rights" */ '../components/power/Rights.vue');
const Roles  = () => import(/* webpackChunkName: "Users_Rights" */ '../components/power/Roles.vue');

// import Cate from '../components/goods/Cate.vue'
// import GoodsList from '../components/goods/List.vue'
const Cate  = () => import(/* webpackChunkName: "Cate_Params" */ '../components/goods/Cate.vue');
const GoodsList  = () => import(/* webpackChunkName: "Cate_Params" */ '../components/goods/List.vue');

// import Params from '../components/goods/Params.vue'
// import Add from '../components/goods/add/Add.vue'
const  Params  = () => import(/* webpackChunkName: "GoodsList_add" */ '../components/goods/Params.vue');
const  Add  = () => import(/* webpackChunkName: "GoodsList_add" */ '../components/goods/add/Add.vue');


// import Orders from '../components/order/Order.vue'
// import Report from '../components/report/Report.vue'
const  Orders =  () => import(/* webpackChunkName: "Order_Report" */ '../components/order/Order.vue');
const  Report =  () => import(/* webpackChunkName: "Order_Report" */ '../components/report/Report.vue');

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'login',
    component: Login
  },
  {
    path: '/home',
    name: 'home',
    component: Home,
    redirect: '/welcome',
    children: [
      {
        path: '/welcome',
        name: 'welcome',
        component: Welcome
      },
      {
        path: '/users',
        component: User
      },
      {
        path: '/rights',
        component: Rights
      },
      {
        path: '/roles',
        component: Roles
      },
      {
        path: '/categories',
        component: Cate
      },
      {
        path: '/goods',
        component: GoodsList
      },
      {
        path: '/params',
        component: Params
      },
      {
        path: '/goods/add',
        component: Add
      },
      {
        path: '/orders',
        component: Orders
      },
      {
        path: '/reports',
        component: Report
      }
    ]
  }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes
});

// 配置前置路由守卫
router.beforeEach(routerBeforeEachdConfig);

export default router
